<template>
	<view class="mainpadding2" style="padding-bottom: 150rpx;">
		<view class="mainpadding_top ffffff radius" v-for="item in list.data" :key="item.id" @click="jumpdetail('/pages/tab4/baoxiaoxq?type=1&id=',item.id)">
			<view class="flexbetween">
				<view class="xiaohong bold titletext">{{item.type.name}}</view>
				<!-- 状态:1=复核员待审核,2=主管待审核,3=经理待审核,4=待打款,5=已完成,6=审核失败 -->
				<view class="xiaohuang main_size" v-if="item.status==1">复核员待审核</view>
				<view class="xiaohuang main_size" v-if="item.status==2">主管待审核</view>
				<view class="xiaohuang main_size" v-if="item.status==3">经理待审核</view>
				<view class="xiaohuang main_size" v-if="item.status==4">待打款</view>
				<view class="xiaolv main_size" v-if="item.status==5">已完成</view>
				<view class="xiaohong main_size" v-if="item.status==6">审核失败</view>
			</view>
			<view class="xiaohei main_size margin_top2 bold">申请金额：￥{{item.price}}</view>
			<view class="xiaohui main_size margin_top2">{{item.des}}</view>
			<view class="flexbetween">
				<view class="xiaohui smalltext">{{item.createtime_text}}</view>
				<view class="flexright margin_top2" v-if="item.status==1">
					<view class="flexleft editbtn margin_right1" @click.stop="jumpdetail('/pages/tab4/baoxiaosq?id=',item.id)">
						<u-icon name="edit-pen" color="#fff" size="16"></u-icon>
						<view class="xiaobai margin_left1 main_size">编辑</view>
					</view>
					<view class="flexleft trashbtn" @click.stop="currentid=item.id;modal.modalShow=true">
						<u-icon name="trash" color="#c1282e" size="16"></u-icon>
						<view class="xiaohong margin_left1 main_size">删除</view>
					</view>
				</view>
			</view>
			
		</view>
		<view class="posibottom mainpadding">
			<view class="submitbtn" style="background-color: #c1282e;" @click="jumpurl('/pages/tab4/baoxiaosq')">添加报销</view>
		</view>
		<moDal :message="modal" @modalSure="modalSure" @modalcancel="modalcancel"></moDal>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				page: 1,
				limit: 12,
				list: {
					data: []
				},
				modal:{
					modalShow:false,
					title:"是否确认删除当前数据？",
				},
				currentid:""
				
			}
		},
		onShow() {
			this.init()
		},
		methods: {
			modalSure(){
				if(this.modal.title=="是否确认删除当前数据？"){
					httpRequest.request("/api/baoxiao/delBaoxiao", 'GET', {
						id:this.currentid
					}).then(res => {
						httpRequest.toast(res.msg)
						if(res.code==1){
							this.init()
						}
					})
				}
				this.modalcancel()
			},
			modalcancel(){
				this.modal.modalShow = false
			},
			init(isPage, page) {
				let _this = this
				httpRequest.request('/api/baoxiao/baoxiaoIndex', 'GET', {
					page: page || 1,
					limit: 12,
					ly:1
				}).then(res => {
					uni.stopPullDownRefresh()
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
		}
	}
</script>
<style lang="scss" scoped>
.editbtn{
		padding: 10rpx 30rpx;
		border-radius: 10rpx;
		background-color: #c1282e;
	}
	.trashbtn{
		padding: 10rpx 30rpx;
		border-radius: 10rpx;
		border: 1rpx solid #c1282e;
	}
</style>
